package top.myegg.java8;

import java.util.ArrayList;
import java.util.List;

public class NewFeaturesTester {
	
	final static String salutation = "Hello";
	
	public static void main(String[] args) {
		List<String> names = new ArrayList<String>();
		
		names.add("zhoushuyi");
		names.add("stepehn");
		names.add("ssssssss");
		//通过system.out::println引用了输出的方法
//		names.forEach(System.out::println);
		
/*		GreetingService gree = message -> System.out.println(salutation + message);
		gree.sayMessage("java8");
		
/*		NewFeaturesTester tester = new NewFeaturesTester();
		
		//带有类型声明的表达式
		MathOperation addition = (int a,int b) -> a+b;
		
		//不带参数类型的表达式
		MathOperation subtraction = (a,b) ->  a-b ;
		
		//带有大括号，带有返回语句的表达式
		MathOperation multiplication = (int a,int b) -> {return  a*b; };
		
		//没有大括号，和return语句的表达式
		MathOperation division = (int a,int b) -> a/b;
		
		System.out.println("10 + 5 ="+ tester.operate(100, 2, addition));
		
		System.out.println("10 - 5 ="+ tester.operate(100, 2, subtraction));
		
		System.out.println("10 x 5 ="+ tester.operate(100, 2, multiplication));
		
		System.out.println("10 / 5 ="+ tester.operate(100, 2, division));
*/	
	}
	
	
	interface MathOperation {
		int operation(int a, int b);
	}
	
	interface GreetingService{
		void sayMessage(String message);
	}
	
	
	private int operate(int a,int b,MathOperation math){
		return math.operation(a, b);
	}
	
}
